FROM ubuntu:16.04

# 中文显示
ENV LANG C.UTF-8

#####################################
# 非 root 用户 :
# Add a non-root user to prevent files being created with root permissions on host machine.
#####################################
ARG PUID=1000
ARG PGID=1000
RUN groupadd -g $PGID chenishr \
	   && useradd -u $PUID -g chenishr -m chenishr

ARG PUID=1002
ARG PGID=1002
RUN groupadd -g $PGID apache \
	   && useradd -u $PUID -g apache -m apache


##########################################
# 安装 vim git 和一些编译工具和依赖包
##########################################
RUN apt-get update && \
	apt-get install -y vim && \
	apt-get install -y zsh && \
	apt-get install -y curl && \
	apt-get install -y wget && \
	apt-get install -y tcpdump && \
	apt-get install -y git 


####################################
# 安装编译工具和依赖包
####################################
USER	root
RUN		apt-get update \
			&& apt-get install -y \
			build-essential \
			gcc \
			g++ \
			autoconf \
			libiconv-hook-dev \
			libmcrypt-dev \
			libxml2-dev \
			libmysqlclient-dev \
			libcurl4-openssl-dev \
			libjpeg8-dev \
			libpng12-dev \
			libfreetype6-dev \
			libssl-dev \
			python \
			python-setuptools \
			iputils-ping \
			net-tools \
			gdb \
			strace \
			ffmpeg \
			linux-tools-common \
			linux-tools-generic \
		&& ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib

# 安装 oh my zsh
RUN 	sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"


# 安装 golang
RUN 	wget https://golang.org/dl/go1.17.2.linux-amd64.tar.gz -O /opt/go1.17.2.linux-amd64.tar.gz && \
		tar -C /usr/local -xzf /opt/go1.17.2.linux-amd64.tar.gz && \
		echo "" >> ~/.zshrc && \
		echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.zshrc

# 导入秘钥
COPY	id_rsa /root/.ssh/id_rsa
COPY	id_rsa.pub /root/.ssh/id_rsa.pub
RUN		chmod 600 /root/.ssh/id_rsa && \
		chmod 644 /root/.ssh/id_rsa.pub


# 容器的启动脚本,运行一个挂起的命令，保持容器不自动退出
USER	root
COPY	init.sh /sbin/my_init.sh
RUN		chmod 755 /sbin/my_init.sh

WORKDIR /var/www/html
ENTRYPOINT	["/sbin/my_init.sh"]